from datetime import timedelta

from redis import StrictRedis


class Config:  # 定义配置类  封装所有配置,方便对配置统一的管理

    DEBUG = True # 设置调试模式
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:mysql@127.0.0.1:3306/info19"
    SQLALCHEMY_TRACK_MODIFICATIONS = False # 追踪数据变化
    REDIS_HOST = "127.0.0.1"   # REDIS ID
    REDIS_PORT = 6379 # REDIS的端口
    SESSION_TYPE = "redis"   # 链接对象
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True # 设置加密
    SESSION_KEY = "QZafYwGeEtby92g36ALwXYVjKtgofNOgT46RZWQuN4Omh37Z2Ua640tQvfdM/Gkg"  # 加密
    PERMANENT_SESSION_LIFETIME = timedelta(days=7)   # 设置过期时间

# 针对不同开发环境 定义配置子类‘

class DevelopmentConfig(Config):   # 开发环境

    DEBUG = True

class ProductConfig(Config):   # 生产环境

    DEBUG = False

config_dict = {
    "dev": DevelopmentConfig,
    "pro": ProductConfig
}